Skip to main content

FSync & FFlush

A buffer can exist in both an application library and the operating system (OS), so “flush” can describe two different boundaries.

fflush moves data from a C library's user-space buffer to the OS. It does not guarantee that the device has stored the bytes durably.

fsync asks the OS to flush a file's pending changes to persistent storage. Because it may wait for the storage device, fsync is generally more expensive than fflush, not faster.

Further discussion: flush versus sync.

Share: